package org.flh.book.shop;

import java.util.ArrayList;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 描述：swagger 文档配置
 *
 * @author 花好月圆
 * @date 2020/11/21 15:00
 */
@Configuration
@EnableSwagger2
@ComponentScan("org.flh.book.shop.controller")
public class SwaggerConfig {

    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(apiInfo())
            .groupName("default")
            .enable(true)
            .select()
            .apis(RequestHandlerSelectors.basePackage("org.flh.book.shop.controller"))
            .paths(a -> !"/user".equals(a))
            .build();
    }

    private ApiInfo apiInfo() {
        Contact contact = new Contact("add", "http://add.flh.org", "1156234567@qq.com");
        return new ApiInfo(
            "书店",
            "一个小的在线书店-api",
            "v1.0",
            "http://team.flh.org",
            contact,
            "MIT License",
            "https://gitee.com/likaipao/book-shop/blob/master/LICENSE",
            new ArrayList<>());
    }

}
